package com.heima.article.controller.v1;

import com.heima.article.service.IArticleHomeService;
import com.heima.model.article.dtos.ArticleHomeDto;
import com.heima.model.common.dtos.ResponseResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author zhouao
 * @date 2022/06/12
 */
@RestController
@RequestMapping("/api/v1/article")
public class ArticleHomeController {

    @Autowired
    private IArticleHomeService service;

    /**
     * 首页加载
     *
     * @param dto dto
     * @return {@link ResponseResult}
     */
    @PostMapping("/load")
    public ResponseResult load(@RequestBody ArticleHomeDto dto) {
        return service.load(dto,null);
    }

    /**
     * 加载更多上拉
     *
     * @param dto dto
     * @return {@link ResponseResult}
     */
    @PostMapping("/loadmore")
    public ResponseResult loadMore(@RequestBody ArticleHomeDto dto) {
        return service.load(dto,1);
    }

    /**
     * 加载新的下拉
     *
     * @param dto dto
     * @return {@link ResponseResult}
     */
    @PostMapping("/loadnew")
    public ResponseResult loadNew(@RequestBody ArticleHomeDto dto) {
        return service.load(dto,2);
    }
}